<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <!-- <el-form-item label="逻辑删除" prop="isDelete">
        <el-input
          v-model.trim="queryParams.isDelete"
          placeholder="请输入逻辑删除"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="下单日期" prop="dataDate">
        <el-date-picker
          clearable
          v-model="queryParams.dataDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择下单日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="品牌" prop="brand">
          <el-input
            v-model.trim="queryParams.brand"
            placeholder="请输入品牌"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商" prop="supplier">
          <el-input
            v-model.trim="queryParams.supplier"
            placeholder="请输入供应商"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="合同号" prop="contractNumber">
          <el-input
            v-model.trim="queryParams.contractNumber"
            placeholder="请输入合同号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="sku" prop="sku">
          <el-input
            v-model.trim="queryParams.sku"
            placeholder="请输入sku"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="采购单号" prop="purchaseOrderNumber">
          <el-input
            v-model.trim="queryParams.purchaseOrderNumber"
            placeholder="请输入采购单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="外部订单号" prop="externalOrderNumber">
          <el-input
            v-model.trim="queryParams.externalOrderNumber"
            placeholder="请输入外部订单号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="损耗件数" prop="lossQuantity">
          <el-input
            v-model.trim="queryParams.lossQuantity"
            placeholder="请输入损耗件数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="新品/老品" prop="isNewProduct">
          <el-input
            v-model.trim="queryParams.isNewProduct"
            placeholder="请输入新品/老品"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="下单数量" prop="orderQuantity">
          <el-input
            v-model.trim="queryParams.orderQuantity"
            placeholder="请输入下单数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="合同采购价" prop="contractPurchasePrice">
          <el-input
            v-model.trim="queryParams.contractPurchasePrice"
            placeholder="请输入合同采购价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="合同采购金额" prop="contractAmount">
          <el-input
            v-model.trim="queryParams.contractAmount"
            placeholder="请输入合同采购金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="是否含税" prop="isTaxIncluded">
          <el-input
            v-model.trim="queryParams.isTaxIncluded"
            placeholder="请输入是否含税"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="单件附加费用" prop="additionalCostPerUnit">
          <el-input
            v-model.trim="queryParams.additionalCostPerUnit"
            placeholder="请输入单件附加费用"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="订单附加费用" prop="orderAdditionalCost">
          <el-input
            v-model.trim="queryParams.orderAdditionalCost"
            placeholder="请输入订单附加费用"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="税率" prop="taxRate">
          <el-input
            v-model.trim="queryParams.taxRate"
            placeholder="请输入税率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceIncludingTax">
          <el-input
            v-model.trim="queryParams.costPriceIncludingTax"
            placeholder="请输入成本裸价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceExcludingTax">
          <el-input
            v-model.trim="queryParams.costPriceExcludingTax"
            placeholder="请输入成本裸价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="交货日期" prop="contractDeliveryDate">
          <el-date-picker
            clearable
            v-model="queryParams.contractDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择交货日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="已入库数量" prop="quantityReceived">
          <el-input
            v-model.trim="queryParams.quantityReceived"
            placeholder="请输入已入库数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="是否有延时" prop="isOverdue30Days">
          <el-input
            v-model.trim="queryParams.isOverdue30Days"
            placeholder="请输入是否有延时"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="延时数" prop="overdueQuantity30Days">
          <el-input
            v-model.trim="queryParams.overdueQuantity30Days"
            placeholder="请输入延时数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="逾期已交货数" prop="overdueDeliveryQuantity">
          <el-input
            v-model.trim="queryParams.overdueDeliveryQuantity"
            placeholder="请输入逾期已交货数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="逾期率" prop="overdueRate">
          <el-input
            v-model.trim="queryParams.overdueRate"
            placeholder="请输入逾期率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="逾期未交付" prop="currentDelayQuantity">
          <el-input
            v-model.trim="queryParams.currentDelayQuantity"
            placeholder="请输入逾期未交付"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="是否超入" prop="isOverOrder">
          <el-input
            v-model.trim="queryParams.isOverOrder"
            placeholder="请输入是否超入"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="超入数量" prop="overOrderQuantity">
          <el-input
            v-model.trim="queryParams.overOrderQuantity"
            placeholder="请输入超入数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="超入库数量" prop="overOrderReceivedQuantity">
          <el-input
            v-model.trim="queryParams.overOrderReceivedQuantity"
            placeholder="请输入超入库数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="年" prop="dataYear">
          <el-input
            v-model.trim="queryParams.dataYear"
            placeholder="请输入年"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="月" prop="dataMonth">
          <el-input
            v-model.trim="queryParams.dataMonth"
            placeholder="请输入月"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['purchase:PurchaseBasicsDwdCopy:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['purchase:PurchaseBasicsDwdCopy:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['purchase:PurchaseBasicsDwdCopy:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['purchase:PurchaseBasicsDwdCopy:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="PurchaseBasicsDwdCopyList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="逻辑删除" align="center" prop="isDelete" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column
        label="下单日期"
        align="center"
        prop="dataDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dataDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="品牌" align="center" prop="brand" />
      <el-table-column label="供应商" align="center" prop="supplier" />
      <el-table-column label="合同号" align="center" prop="contractNumber" />
      <el-table-column label="合同类型" align="center" prop="contractType" />
      <el-table-column label="sku" align="center" prop="sku" />
      <el-table-column label="订单状态" align="center" prop="orderStatus" />
      <el-table-column label="收货状态" align="center" prop="receiptStatus" />
      <el-table-column
        label="采购单号"
        align="center"
        prop="purchaseOrderNumber"
      />
      <el-table-column
        label="外部订单号"
        align="center"
        prop="externalOrderNumber"
      />
      <el-table-column label="损耗件数" align="center" prop="lossQuantity" />
      <el-table-column label="新品/老品" align="center" prop="isNewProduct" />
      <el-table-column label="下单数量" align="center" prop="orderQuantity" />
      <el-table-column
        label="合同采购价"
        align="center"
        prop="contractPurchasePrice"
      />
      <el-table-column
        label="合同采购金额"
        align="center"
        prop="contractAmount"
      />
      <el-table-column label="是否含税" align="center" prop="isTaxIncluded" />
      <el-table-column
        label="单件附加费用"
        align="center"
        prop="additionalCostPerUnit"
      />
      <el-table-column
        label="订单附加费用"
        align="center"
        prop="orderAdditionalCost"
      />
      <el-table-column
        label="附加费用说明"
        align="center"
        prop="additionalCostDescription"
      />
      <el-table-column label="税率" align="center" prop="taxRate" />
      <el-table-column
        label="成本裸价"
        align="center"
        prop="costPriceIncludingTax"
      />
      <el-table-column
        label="成本裸价"
        align="center"
        prop="costPriceExcludingTax"
      />
      <el-table-column
        label="交货日期"
        align="center"
        prop="contractDeliveryDate"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.contractDeliveryDate, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="已入库数量"
        align="center"
        prop="quantityReceived"
      />
      <el-table-column
        label="是否有延时"
        align="center"
        prop="isOverdue30Days"
      />
      <el-table-column
        label="延时数"
        align="center"
        prop="overdueQuantity30Days"
      />
      <el-table-column
        label="逾期已交货数"
        align="center"
        prop="overdueDeliveryQuantity"
      />
      <el-table-column label="逾期率" align="center" prop="overdueRate" />
      <el-table-column
        label="逾期未交付"
        align="center"
        prop="currentDelayQuantity"
      />
      <el-table-column label="是否超入" align="center" prop="isOverOrder" />
      <el-table-column
        label="超入数量"
        align="center"
        prop="overOrderQuantity"
      />
      <el-table-column
        label="超入库数量"
        align="center"
        prop="overOrderReceivedQuantity"
      />
      <el-table-column label="备注" align="center" prop="remarks" />
      <el-table-column label="年" align="center" prop="dataYear" />
      <el-table-column label="月" align="center" prop="dataMonth" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['purchase:PurchaseBasicsDwdCopy:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['purchase:PurchaseBasicsDwdCopy:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改采购基础副本对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="逻辑删除" prop="isDelete">
          <el-input v-model.trim="form.isDelete" placeholder="请输入逻辑删除" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model.trim="form.remark" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="下单日期" prop="dataDate">
          <el-date-picker
            clearable
            v-model="form.dataDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择下单日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model.trim="form.brand" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="供应商" prop="supplier">
          <el-input v-model.trim="form.supplier" placeholder="请输入供应商" />
        </el-form-item>
        <el-form-item label="合同号" prop="contractNumber">
          <el-input
            v-model.trim="form.contractNumber"
            placeholder="请输入合同号"
          />
        </el-form-item>
        <el-form-item label="sku" prop="sku">
          <el-input v-model.trim="form.sku" placeholder="请输入sku" />
        </el-form-item>
        <el-form-item label="采购单号" prop="purchaseOrderNumber">
          <el-input
            v-model.trim="form.purchaseOrderNumber"
            placeholder="请输入采购单号"
          />
        </el-form-item>
        <el-form-item label="外部订单号" prop="externalOrderNumber">
          <el-input
            v-model.trim="form.externalOrderNumber"
            placeholder="请输入外部订单号"
          />
        </el-form-item>
        <el-form-item label="损耗件数" prop="lossQuantity">
          <el-input
            v-model.trim="form.lossQuantity"
            placeholder="请输入损耗件数"
          />
        </el-form-item>
        <el-form-item label="新品/老品" prop="isNewProduct">
          <el-input
            v-model.trim="form.isNewProduct"
            placeholder="请输入新品/老品"
          />
        </el-form-item>
        <el-form-item label="下单数量" prop="orderQuantity">
          <el-input
            v-model.trim="form.orderQuantity"
            placeholder="请输入下单数量"
          />
        </el-form-item>
        <el-form-item label="合同采购价" prop="contractPurchasePrice">
          <el-input
            v-model.trim="form.contractPurchasePrice"
            placeholder="请输入合同采购价"
          />
        </el-form-item>
        <el-form-item label="合同采购金额" prop="contractAmount">
          <el-input
            v-model.trim="form.contractAmount"
            placeholder="请输入合同采购金额"
          />
        </el-form-item>
        <el-form-item label="是否含税" prop="isTaxIncluded">
          <el-input
            v-model.trim="form.isTaxIncluded"
            placeholder="请输入是否含税"
          />
        </el-form-item>
        <el-form-item label="单件附加费用" prop="additionalCostPerUnit">
          <el-input
            v-model.trim="form.additionalCostPerUnit"
            placeholder="请输入单件附加费用"
          />
        </el-form-item>
        <el-form-item label="订单附加费用" prop="orderAdditionalCost">
          <el-input
            v-model.trim="form.orderAdditionalCost"
            placeholder="请输入订单附加费用"
          />
        </el-form-item>
        <el-form-item label="附加费用说明" prop="additionalCostDescription">
          <el-input
            v-model.trim="form.additionalCostDescription"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="税率" prop="taxRate">
          <el-input v-model.trim="form.taxRate" placeholder="请输入税率" />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceIncludingTax">
          <el-input
            v-model.trim="form.costPriceIncludingTax"
            placeholder="请输入成本裸价"
          />
        </el-form-item>
        <el-form-item label="成本裸价" prop="costPriceExcludingTax">
          <el-input
            v-model.trim="form.costPriceExcludingTax"
            placeholder="请输入成本裸价"
          />
        </el-form-item>
        <el-form-item label="交货日期" prop="contractDeliveryDate">
          <el-date-picker
            clearable
            v-model="form.contractDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择交货日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="已入库数量" prop="quantityReceived">
          <el-input
            v-model.trim="form.quantityReceived"
            placeholder="请输入已入库数量"
          />
        </el-form-item>
        <el-form-item label="是否有延时" prop="isOverdue30Days">
          <el-input
            v-model.trim="form.isOverdue30Days"
            placeholder="请输入是否有延时"
          />
        </el-form-item>
        <el-form-item label="延时数" prop="overdueQuantity30Days">
          <el-input
            v-model.trim="form.overdueQuantity30Days"
            placeholder="请输入延时数"
          />
        </el-form-item>
        <el-form-item label="逾期已交货数" prop="overdueDeliveryQuantity">
          <el-input
            v-model.trim="form.overdueDeliveryQuantity"
            placeholder="请输入逾期已交货数"
          />
        </el-form-item>
        <el-form-item label="逾期率" prop="overdueRate">
          <el-input
            v-model.trim="form.overdueRate"
            placeholder="请输入逾期率"
          />
        </el-form-item>
        <el-form-item label="逾期未交付" prop="currentDelayQuantity">
          <el-input
            v-model.trim="form.currentDelayQuantity"
            placeholder="请输入逾期未交付"
          />
        </el-form-item>
        <el-form-item label="是否超入" prop="isOverOrder">
          <el-input
            v-model.trim="form.isOverOrder"
            placeholder="请输入是否超入"
          />
        </el-form-item>
        <el-form-item label="超入数量" prop="overOrderQuantity">
          <el-input
            v-model.trim="form.overOrderQuantity"
            placeholder="请输入超入数量"
          />
        </el-form-item>
        <el-form-item label="超入库数量" prop="overOrderReceivedQuantity">
          <el-input
            v-model.trim="form.overOrderReceivedQuantity"
            placeholder="请输入超入库数量"
          />
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input
            v-model.trim="form.remarks"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="年" prop="dataYear">
          <el-input v-model.trim="form.dataYear" placeholder="请输入年" />
        </el-form-item>
        <el-form-item label="月" prop="dataMonth">
          <el-input v-model.trim="form.dataMonth" placeholder="请输入月" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPurchaseBasicsDwdCopy,
  getPurchaseBasicsDwdCopy,
  delPurchaseBasicsDwdCopy,
  addPurchaseBasicsDwdCopy,
  updatePurchaseBasicsDwdCopy,
} from "@/api/productAllocation/PurchaseBasicsDwdCopy";

export default {
  name: "PurchaseBasicsDwdCopy",
  data() {
    return {
      isOpen: false,
      inputValue: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购基础副本表格数据
      PurchaseBasicsDwdCopyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        isDelete: null,
        dataDate: null,
        brand: null,
        supplier: null,
        contractNumber: null,
        contractType: null,
        sku: null,
        orderStatus: null,
        receiptStatus: null,
        purchaseOrderNumber: null,
        externalOrderNumber: null,
        lossQuantity: null,
        isNewProduct: null,
        orderQuantity: null,
        contractPurchasePrice: null,
        contractAmount: null,
        isTaxIncluded: null,
        additionalCostPerUnit: null,
        orderAdditionalCost: null,
        additionalCostDescription: null,
        taxRate: null,
        costPriceIncludingTax: null,
        costPriceExcludingTax: null,
        contractDeliveryDate: null,
        quantityReceived: null,
        isOverdue30Days: null,
        overdueQuantity30Days: null,
        overdueDeliveryQuantity: null,
        overdueRate: null,
        currentDelayQuantity: null,
        isOverOrder: null,
        overOrderQuantity: null,
        overOrderReceivedQuantity: null,
        remarks: null,
        dataYear: null,
        dataMonth: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询采购基础副本列表 */
    getList() {
      this.loading = true;
      listPurchaseBasicsDwdCopy(this.queryParams).then((response) => {
        this.PurchaseBasicsDwdCopyList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDelete: null,
        remark: null,
        dataDate: null,
        brand: null,
        supplier: null,
        contractNumber: null,
        contractType: null,
        sku: null,
        orderStatus: null,
        receiptStatus: null,
        purchaseOrderNumber: null,
        externalOrderNumber: null,
        lossQuantity: null,
        isNewProduct: null,
        orderQuantity: null,
        contractPurchasePrice: null,
        contractAmount: null,
        isTaxIncluded: null,
        additionalCostPerUnit: null,
        orderAdditionalCost: null,
        additionalCostDescription: null,
        taxRate: null,
        costPriceIncludingTax: null,
        costPriceExcludingTax: null,
        contractDeliveryDate: null,
        quantityReceived: null,
        isOverdue30Days: null,
        overdueQuantity30Days: null,
        overdueDeliveryQuantity: null,
        overdueRate: null,
        currentDelayQuantity: null,
        isOverOrder: null,
        overOrderQuantity: null,
        overOrderReceivedQuantity: null,
        remarks: null,
        dataYear: null,
        dataMonth: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加采购基础副本";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPurchaseBasicsDwdCopy(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改采购基础副本";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updatePurchaseBasicsDwdCopy(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPurchaseBasicsDwdCopy(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除采购基础副本编号为"' + ids + '"的数据项？')
        .then(function () {
          return delPurchaseBasicsDwdCopy(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "purchase/PurchaseBasicsDwdCopy/export",
        {
          ...this.queryParams,
        },
        `PurchaseBasicsDwdCopy_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
